<template>
  <!-- 输入框 -->
  <header class="header">
    <h1>小黑记事本</h1>
    <input placeholder="请输入任务" class="new-todo" v-model="inputTask" @keyup.enter="addTask" />
    <button class="add" @click="addTask()">添加任务</button>
  </header>
</template>

<script>

export default {
  data(){
    return{
      inputTask: ""
    }
  },
  methods: {
    addTask() {
      if (this.inputTask.trim()==""){
        alert("请输入任务")
        return
      }
      this.$emit('handleAddTask', this.inputTask)
      this.inputTask=""
    }
  }
}
</script>

<style>

</style>

